#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

ll qmi(ll a, ll b)
{
    ll res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return res;
}
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
        return x;
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); // 时间戳
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> st(n + 1);
    vector<vector<int>> w(m + 1);
    for (int i = 1; i <= m; i++)
    {
        int k;
        cin >> k;
        while (k--)
        {
            int x;
            cin >> x;
            w[i].push_back(x);
        }
    }
    vector<int> p(m + 1);
    for (int i = 1; i <= m; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    auto dfs = [&](auto &&dfs, int u)
    {
        if (u > n)
        {
            int t = 0;
            for(int i = 1; i <= m; i++)
            {
                int cnt = 0;
                for(auto x : w[i])
                {
                    if(st[x]) cnt++;
                }
                if(cnt % 2 == p[i])
                    t++;
            }
            if(t == m) ans++;
            return;
        }

            st[u] = true;
            dfs(dfs, u + 1);
            st[u] = false;
            dfs(dfs, u + 1);
    };
    st[1] = true;
    dfs(dfs, 2);
    st[1] = false;
    dfs(dfs, 2);
    cout << ans << endl;
    return 0;
}